迴圈 for...of


Posted by mijouhsieh on 2023-03-15

for ...in for...of foraEach Object.keys()

for...of MDN

The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object.

Iterable objects include instances of built-ins such as Array, String, TypedArray, Map, Set, NodeList (and other DOM collections), as well as the arguments object, generators produced by generator functions, and user-defined iterables.

const todos = ['Hit the gym', 'Read a book', 'Buy eggs', 'Organize office', 'Pay bills']
for (let todo of todos) {
   console.log(todo)
}

#for-of







Related Posts

[ JS101] JavaScript 內建函式

[ JS101] JavaScript 內建函式

PHP & MySQL 陽春留言板實作

PHP & MySQL 陽春留言板實作

[Week 2] JavaScript - 變數、陣列、物件、== 與 ===

[Week 2] JavaScript - 變數、陣列、物件、== 與 ===


Comments